<template>
  <div id="app">
    <!-- <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item>1</van-swipe-item>
      <van-swipe-item>2</van-swipe-item>
      <van-swipe-item>3</van-swipe-item>
      <van-swipe-item>4</van-swipe-item>
    </van-swipe> -->
    <!-- 3.当做标签使用 -->
    <!-- <comA
      v-for="(song, index) in hotSangs"
      v-bind:key="index"
      :name="song.name"
      :artist="song.artist"
      :rank="index+1"
      :rate="5-index"
    ></comA> -->
    <!-- <cart></cart> -->
    <!-- <van-button type="primary" @click="getData">主要按钮11</van-button> -->
    <!-- <img :src="pic" alt=""> -->
    <!-- 路由出口，可以看做是一个变量，随着url变化，变成不同的组件 -->
    <router-view />
  </div>
</template>

<script>
// 1.导入外部文件
import comA from "./components/componentA.vue";
import cart from "./components/cart.vue";
export default {
  name: "App",
  data() {
    return {
      // 专辑封面
      pic: '',
      hotSangs: [
        { name: "学猫叫", artist: "于谦" },
        { name: "河东狮吼", artist: "腾格尔" },
        { name: "real", artist: "韩红" },
      ],
    };
  },
  // 2.注册组件
  components: {
    comA: comA,
    cart
  },
  created() {
    this.getData();
  },
  methods: {
    // 获取数据
    getData() {
      // 1.发请求 Promise
      this.$http.get('https://api.imjad.cn/cloudmusic/?type=detail&id=28012031&br=128000')
        // 2.成功的回调 
        .then(res => {
          this.pic = res.data.songs[0].al.picUrl;
        })
        // 3.失败的回调
        .catch(err => {
          console.log(err);
        })
    }
  },
};
</script>

<style>
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* text-align: center;
  color: #2c3e50;
  margin-top: 60px; */
}
.my-swipe .van-swipe-item {
    color: #fff;
    font-size: 20px;
    line-height: 150px;
    text-align: center;
    background-color: #39a9ed;
  }
</style>
